﻿<?xml version="1.0" encoding="utf-8" ?>
<AdoNetDataAccess connection="$ArticleDBConnection$" formatter="bizobj of CalendarEvent">
	<Sql>
		SELECT        
			a.id, a.baseTitle, a.summary AS baseSummary, a.body AS baseBody,
			t.objectId, t.parentId, t.parentHostId, nc.keyName, nc.depth, nc.rootId, nc.treeName,
			cal.extraContentId AS extraContent_id, cal.startTime,cal.endTime,cal.eventTypeId AS type_id,
			cal.calendarId, cal.allDayEvent, cal.maxCapacity,
			calEv.foreColor AS type_foreColor, calEv.backColor AS type_backColor,
			calEv.useColorForDateArea AS type_useColorForDateArea, calEv.allowEnrollment AS type_allowEnrollment,
			ad.id as location_id, ad.street1 as location_street1, ad.city as location_city, ad.stateProvince as location_stateProvince,
			ad.zipCode as location_zipCode ,latitude as location_latitude ,longitude as location_longitude,
			cn.code as location_country_regionCode, cn.englishName as location_country_englishName
			
			FROM Articles AS a 
			JOIN CalendarEvents as cal on a.id = cal.id
			JOIN ObjectTreeNodes AS t ON a.id = t.objectId 
			JOIN ObjectTreeCounts AS nc on nc.objectId = a.id
			LEFT OUTER JOIN CalendarEventTypes as calEv on calEv.id = cal.eventTypeId
			LEFT OUTER JOIN Addresses AS ad on ad.id = cal.locationId
			LEFT OUTER JOIN Countries as cn on cn.code  = ad.countryCode
			WHERE 
				cal.id = @eventId;
	</Sql>
	<Param name="eventId" type="UniqueIdentifier" />
</AdoNetDataAccess>
